#define _CRT_SECURE_NO_WARNINGS


#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
int n;
struct node
{
	int l;
	int r;
}a[N];
bool cmp(node& x, node& y)
{
	return x.l < y.l;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int l, r;
		cin >> a[i].l >> a[i].r;
	}
	sort(a + 1, a + 1 + n, cmp);

	int ret = 1;
	int r = a[1].r;

	for (int i = 2; i <= n; i++)
	{
		if (a[i].l < r)
			r = min(r, a[i].r);
		else
		{
			ret++;
			r = a[i].r;
		}
	}
	cout << ret;
	return 0;
}


